<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  <head>
    <meta name="Content-Type" content="text/html; charset=UTF-8" />
<title>Module: Sass::Util</title>
<link rel="stylesheet" href="style.css" tppabs="http://sass-lang.com/docs/yardoc/css/style.css" type="text/css" media="screen" charset="utf-8" />
<link rel="stylesheet" href="common.css" tppabs="http://sass-lang.com/docs/yardoc/css/common.css" type="text/css" media="screen" charset="utf-8" />

<script type="text/javascript" charset="utf-8">
  relpath = '..';
  if (relpath != '') relpath += '/';
</script>
<script type="text/javascript" charset="utf-8" src="jquery.js" tppabs="http://sass-lang.com/docs/yardoc/js/jquery.js"></script>
<script type="text/javascript" charset="utf-8" src="app.js" tppabs="http://sass-lang.com/docs/yardoc/js/app.js"></script>

  </head>
  <body>
    <script type="text/javascript" charset="utf-8">
      if (window.top.frames.main) document.body.className = 'frames';
    </script>
    
    <div id="header">
      <div id="menu">
  
    <a href="_index.html" tppabs="http://sass-lang.com/docs/yardoc/_index.html">Index (U)</a> &raquo; 
    <span class='title'><a href="Sass-1.html" tppabs="http://sass-lang.com/docs/yardoc/Sass.html" title="Sass (module)">Sass</a></span>
     &raquo; 
    <span class="title">Util</span>
  
  
  <div class="noframes"><span class="title">(</span><a href="javascript:if(confirm(%27http://sass-lang.com/docs/yardoc/Sass/.  \n\nThis file was not retrieved by Teleport Pro, because the server reports that this file cannot be found.  \n\nDo you want to open it from the server?%27))window.location=%27http://sass-lang.com/docs/yardoc/Sass/.%27" tppabs="http://sass-lang.com/docs/yardoc/Sass/." target="_top">no frames</a><span class="title">)</span></div>
</div>

      <div id="search">
  <a id="class_list_link" href="#">Class List</a>
  <a id="method_list_link" href="#">Method List</a>
  <a id ="file_list_link" href="#">File List</a>
</div>

      <div class="clear"></div>
    </div>
    
    <iframe id="search_frame"></iframe>
    
    <div id="content"><h1>Module: Sass::Util 
  
  
</h1>

<dl class="box">
  
  
    
      <dt class="r1">Extends:</dt>
      <dd class="r1"><a href="" title="Sass::Util (module)">Util</a></dd>
      
    
  
    
  
  
    <dt class="r2 last">Defined in:</dt>
    <dd class="r2 last">/var/www/sass-pages/.sass/lib/sass/util.rb<span class="defines">,<br />
  /var/www/sass-pages/.sass/lib/sass/util/subset_map.rb</span>
</dd>
  
</dl>
<div class="clear"></div>

<h2>Overview</h2><div class="docstring">
  <div class="discussion">
    <p>A module containing various useful functions.</p>

  </div>
</div>
<div class="tags">
  
</div><h2>Defined Under Namespace</h2>
<p class="children">
   
    
   
    
      <strong class="classes">Classes:</strong> <a href="StaticConditionalContext.html" tppabs="http://sass-lang.com/docs/yardoc/Sass/Util/StaticConditionalContext.html" title="Sass::Util::StaticConditionalContext (class)">StaticConditionalContext</a>, <a href="SubsetMap.html" tppabs="http://sass-lang.com/docs/yardoc/Sass/Util/SubsetMap.html" title="Sass::Util::SubsetMap (class)">SubsetMap</a>
    
  
</p>

  <h2>Constant Summary</h2>
  
    <dl class="constants">
      
        <dt id="RUBY_VERSION-constant" class="">RUBY_VERSION =
            <span class="summary_desc">An array of ints representing the Ruby version number.</span>
        </dt>
        <dd><pre class="code">::RUBY_VERSION.split(".").map {</pre></dd>
      
        <dt id="RUBY_ENGINE-constant" class="">RUBY_ENGINE =
            <span class="summary_desc">The Ruby engine we&#8217;re running under.</span>
        </dt>
        <dd><pre class="code">defined?(::RUBY_ENGINE) ? ::RUBY_ENGINE : "ruby"</pre></dd>
      
    </dl>
  



  <h2>Instance Method Summary</h2>

  <ul class="summary">
    
      <li class="public ">
  <span class="summary_signature">
    
      <a href="#abstract-instance_method" title="#abstract (instance method)">- <strong>abstract</strong>(obj) </a>
    

    
  </span>
  
  
  
  
  

  
    <span class="summary_desc">Throws a NotImplementedError for an abstract method.</span>
  
</li>

    
      <li class="public ">
  <span class="summary_signature">
    
      <a href="#ap_geq%3F-instance_method" title="#ap_geq? (instance method)">- (Boolean) <strong>ap_geq?</strong>(version) </a>
    

    
  </span>
  
  
  
  
  

  
    <span class="summary_desc">Returns whether this environment is using ActionPack of a version greater than or equal to that specified.</span>
  
</li>

    
      <li class="public ">
  <span class="summary_signature">
    
      <a href="#ap_geq_3%3F-instance_method" title="#ap_geq_3? (instance method)">- (Boolean) <strong>ap_geq_3?</strong> </a>
    

    
  </span>
  
  
  
  
  

  
    <span class="summary_desc">Returns whether this environment is using ActionPack version 3.0.0 or greater.</span>
  
</li>

    
      <li class="public ">
  <span class="summary_signature">
    
      <a href="#array_minus-instance_method" title="#array_minus (instance method)">- (Array) <strong>array_minus</strong>(minuend, subtrahend) </a>
    

    
  </span>
  
  
  
  
  

  
    <span class="summary_desc">Returns a sub-array of <code>minuend</code> containing only elements that are also in <code>subtrahend</code>.</span>
  
</li>

    
      <li class="public ">
  <span class="summary_signature">
    
      <a href="#av_template_class-instance_method" title="#av_template_class (instance method)">- <strong>av_template_class</strong>(name) </a>
    

    
  </span>
  
  
  
  
  

  
    <span class="summary_desc">Returns an ActionView::Template* class.</span>
  
</li>

    
      <li class="public ">
  <span class="summary_signature">
    
      <a href="#caller_info-instance_method" title="#caller_info (instance method)">- ([String, Fixnum, (String, nil)]) <strong>caller_info</strong>(entry = nil) </a>
    

    
  </span>
  
  
  
  
  

  
    <span class="summary_desc">Returns information about the caller of the previous method.</span>
  
</li>

    
      <li class="public ">
  <span class="summary_signature">
    
      <a href="#check_encoding-instance_method" title="#check_encoding (instance method)">- (String) <strong>check_encoding</strong>(str) {|msg| ... }</a>
    

    
  </span>
  
  
  
  
  

  
    <span class="summary_desc">Checks that the encoding of a string is valid in Ruby 1.9 and cleans up potential encoding gotchas like the UTF-8 BOM.</span>
  
</li>

    
      <li class="public ">
  <span class="summary_signature">
    
      <a href="#check_range-instance_method" title="#check_range (instance method)">- (Numeric) <strong>check_range</strong>(name, range, value, unit = '') </a>
    

    
  </span>
  
  
  
  
  

  
    <span class="summary_desc">Asserts that <code>value</code> falls within <code>range</code> (inclusive), leaving room for slight floating-point errors.</span>
  
</li>

    
      <li class="public ">
  <span class="summary_signature">
    
      <a href="#check_sass_encoding-instance_method" title="#check_sass_encoding (instance method)">- ((String, Encoding)) <strong>check_sass_encoding</strong>(str, &amp;block) {|msg| ... }</a>
    

    
  </span>
  
  
  
  
  

  
    <span class="summary_desc">Like <tt><a href="#check_encoding-instance_method" title="Sass::Util#check_encoding (method)">#check_encoding</a></tt>, but also checks for a <code>@charset</code> declaration at the beginning of the file and uses that encoding if it exists.</span>
  
</li>

    
      <li class="public ">
  <span class="summary_signature">
    
      <a href="#destructure-instance_method" title="#destructure (instance method)">- (Object) <strong>destructure</strong>(val) </a>
    

    
  </span>
  
  
  
  
  

  
    <span class="summary_desc">Prepare a value for a destructuring assignment (e.g. <code>a, b =
val</code>).</span>
  
</li>

    
      <li class="public ">
  <span class="summary_signature">
    
      <a href="#enum_cons-instance_method" title="#enum_cons (instance method)">- (Enumerator) <strong>enum_cons</strong>(enum, n) </a>
    

    
  </span>
  
  
  
  
  

  
    <span class="summary_desc">A version of <code>Enumerable#enum_cons</code> that works in Ruby 1.8 and 1.9.</span>
  
</li>

    
      <li class="public ">
  <span class="summary_signature">
    
      <a href="#enum_slice-instance_method" title="#enum_slice (instance method)">- (Enumerator) <strong>enum_slice</strong>(enum, n) </a>
    

    
  </span>
  
  
  
  
  

  
    <span class="summary_desc">A version of <code>Enumerable#enum_slice</code> that works in Ruby 1.8 and 1.9.</span>
  
</li>

    
      <li class="public ">
  <span class="summary_signature">
    
      <a href="#enum_with_index-instance_method" title="#enum_with_index (instance method)">- (Enumerator) <strong>enum_with_index</strong>(enum) </a>
    

    
  </span>
  
  
  
  
  

  
    <span class="summary_desc">A version of <code>Enumerable#enum_with_index</code> that works in Ruby 1.8 and 1.9.</span>
  
</li>

    
      <li class="public ">
  <span class="summary_signature">
    
      <a href="#extract%21-instance_method" title="#extract! (instance method)">- (Array) <strong>extract!</strong>(array) {|el| ... }</a>
    

    
  </span>
  
  
  
  
  

  
    <span class="summary_desc">Destructively removes all elements from an array that match a block, and returns the removed elements.</span>
  
</li>

    
      <li class="public ">
  <span class="summary_signature">
    
      <a href="#extract_values-instance_method" title="#extract_values (instance method)">- ((String, Array)) <strong>extract_values</strong>(arr) </a>
    

    
  </span>
  
  
  
  
  

  
    <span class="summary_desc">Extracts the non-string vlaues from an array containing both strings and non-strings.</span>
  
</li>

    
      <li class="public ">
  <span class="summary_signature">
    
      <a href="#flatten-instance_method" title="#flatten (instance method)">- (Array) <strong>flatten</strong>(arr, n) </a>
    

    
  </span>
  
  
  
  
  

  
    <span class="summary_desc">Flattens the first <code>n</code> nested arrays in a cross-version manner.</span>
  
</li>

    
      <li class="public ">
  <span class="summary_signature">
    
      <a href="#glob-instance_method" title="#glob (instance method)">- <strong>glob</strong>(path, &amp;block) </a>
    

    
  </span>
  
  
  
  
  

  
    <span class="summary_desc">Like <code>Dir.glob</code>, but works with backslash-separated paths on Windows.</span>
  
</li>

    
      <li class="public ">
  <span class="summary_signature">
    
      <a href="#group_by_to_a-instance_method" title="#group_by_to_a (instance method)">- (Array&lt;[Object, Array]&gt;) <strong>group_by_to_a</strong>(enum, &amp;block) </a>
    

    
  </span>
  
  
  
  
  

  
    <span class="summary_desc">Performs the equivalent of <code>enum.group_by.to_a</code>, but with a guaranteed order.</span>
  
</li>

    
      <li class="public ">
  <span class="summary_signature">
    
      <a href="#has%3F-instance_method" title="#has? (instance method)">- (Boolean) <strong>has?</strong>(attr, klass, method) </a>
    

    
  </span>
  
  
  
  
  

  
    <span class="summary_desc">Checks to see if a class has a given method.</span>
  
</li>

    
      <li class="public ">
  <span class="summary_signature">
    
      <a href="#hash_to_a-instance_method" title="#hash_to_a (instance method)">- (Array) <strong>hash_to_a</strong>(hash) </a>
    

    
  </span>
  
  
  
  
  

  
    <span class="summary_desc">Converts a Hash to an Array.</span>
  
</li>

    
      <li class="public ">
  <span class="summary_signature">
    
      <a href="#inject_values-instance_method" title="#inject_values (instance method)">- (Array) <strong>inject_values</strong>(str, values) </a>
    

    
  </span>
  
  
  
  
  

  
    <span class="summary_desc">Undoes <tt><a href="#extract_values-instance_method" title="Sass::Util#extract_values (method)">#extract_values</a></tt> by transforming a string with escape sequences into an array of strings and non-string values.</span>
  
</li>

    
      <li class="public ">
  <span class="summary_signature">
    
      <a href="#inspect_obj-instance_method" title="#inspect_obj (instance method)">- (String) <strong>inspect_obj</strong>(obj) </a>
    

    
  </span>
  
  
  
  
  

  
    <span class="summary_desc">Like <code>Object#inspect</code>, but preserves non-ASCII characters rather than escaping them under Ruby 1.9.2.</span>
  
</li>

    
      <li class="public ">
  <span class="summary_signature">
    
      <a href="#intersperse-instance_method" title="#intersperse (instance method)">- (Array) <strong>intersperse</strong>(enum, val) </a>
    

    
  </span>
  
  
  
  
  

  
    <span class="summary_desc">Intersperses a value in an enumerable, as would be done with <code>Array#join</code> but without concatenating the array together afterwards.</span>
  
</li>

    
      <li class="public ">
  <span class="summary_signature">
    
      <a href="#ironruby%3F-instance_method" title="#ironruby? (instance method)">- (Boolean) <strong>ironruby?</strong> </a>
    

    
  </span>
  
  
  
  
  

  
    <span class="summary_desc">Whether or not this is running on IronRuby.</span>
  
</li>

    
      <li class="public ">
  <span class="summary_signature">
    
      <a href="#jruby1_6%3F-instance_method" title="#jruby1_6? (instance method)">- (Boolean) <strong>jruby1_6?</strong> </a>
    

    
  </span>
  
  
  
  
  

  
    <span class="summary_desc">Wehter or not this is running under JRuby 1.6 or lower.</span>
  
</li>

    
      <li class="public ">
  <span class="summary_signature">
    
      <a href="#jruby%3F-instance_method" title="#jruby? (instance method)">- (Boolean) <strong>jruby?</strong> </a>
    

    
  </span>
  
  
  
  
  

  
    <span class="summary_desc">Whether or not this is running on JRuby.</span>
  
</li>

    
      <li class="public ">
  <span class="summary_signature">
    
      <a href="#jruby_version-instance_method" title="#jruby_version (instance method)">- (Array&lt;Fixnum&gt;) <strong>jruby_version</strong> </a>
    

    
  </span>
  
  
  
  
  

  
    <span class="summary_desc">Returns an array of ints representing the JRuby version number.</span>
  
</li>

    
      <li class="public ">
  <span class="summary_signature">
    
      <a href="#lcs-instance_method" title="#lcs (instance method)">- (Array) <strong>lcs</strong>(x, y, &amp;block) {|a, b| ... }</a>
    

    
  </span>
  
  
  
  
  

  
    <span class="summary_desc">Computes a single longest common subsequence for <code>x</code> and <code>y</code>.</span>
  
</li>

    
      <li class="public ">
  <span class="summary_signature">
    
      <a href="#macruby%3F-instance_method" title="#macruby? (instance method)">- (Boolean) <strong>macruby?</strong> </a>
    

    
  </span>
  
  
  
  
  

  
    <span class="summary_desc">Whether or not this is running under MacRuby.</span>
  
</li>

    
      <li class="public ">
  <span class="summary_signature">
    
      <a href="#map_hash-instance_method" title="#map_hash (instance method)">- (Hash) <strong>map_hash</strong>(hash) {|key, value| ... }</a>
    

    
  </span>
  
  
  
  
  

  
    <span class="summary_desc">Maps the key-value pairs of a hash according to a block.</span>
  
</li>

    
      <li class="public ">
  <span class="summary_signature">
    
      <a href="#map_keys-instance_method" title="#map_keys (instance method)">- (Hash) <strong>map_keys</strong>(hash) {|key| ... }</a>
    

    
  </span>
  
  
  
  
  

  
    <span class="summary_desc">Maps the keys in a hash according to a block.</span>
  
</li>

    
      <li class="public ">
  <span class="summary_signature">
    
      <a href="#map_vals-instance_method" title="#map_vals (instance method)">- (Hash) <strong>map_vals</strong>(hash) {|value| ... }</a>
    

    
  </span>
  
  
  
  
  

  
    <span class="summary_desc">Maps the values in a hash according to a block.</span>
  
</li>

    
      <li class="public ">
  <span class="summary_signature">
    
      <a href="#merge_adjacent_strings-instance_method" title="#merge_adjacent_strings (instance method)">- (Array) <strong>merge_adjacent_strings</strong>(arr) </a>
    

    
  </span>
  
  
  
  
  

  
    <span class="summary_desc">Concatenates all strings that are adjacent in an array, while leaving other elements as they are.</span>
  
</li>

    
      <li class="public ">
  <span class="summary_signature">
    
      <a href="#ord-instance_method" title="#ord (instance method)">- (Fixnum) <strong>ord</strong>(c) </a>
    

    
  </span>
  
  
  
  
  

  
    <span class="summary_desc">Returns the ASCII code of the given character.</span>
  
</li>

    
      <li class="public ">
  <span class="summary_signature">
    
      <a href="#paths-instance_method" title="#paths (instance method)">- (Array&lt;Arrays&gt;) <strong>paths</strong>(arrs) </a>
    

    
  </span>
  
  
  
  
  

  
    <span class="summary_desc">Return an array of all possible paths through the given arrays.</span>
  
</li>

    
      <li class="public ">
  <span class="summary_signature">
    
      <a href="#powerset-instance_method" title="#powerset (instance method)">- (Set&lt;Set&gt;) <strong>powerset</strong>(arr) </a>
    

    
  </span>
  
  
  
  
  

  
    <span class="summary_desc">Computes the powerset of the given array.</span>
  
</li>

    
      <li class="public ">
  <span class="summary_signature">
    
      <a href="#rails_env-instance_method" title="#rails_env (instance method)">- (String<sup>?</sup>) <strong>rails_env</strong> </a>
    

    
  </span>
  
  
  
  
  

  
    <span class="summary_desc">Returns the environment of the Rails application, if this is running in a Rails context.</span>
  
</li>

    
      <li class="public ">
  <span class="summary_signature">
    
      <a href="#rails_root-instance_method" title="#rails_root (instance method)">- (String<sup>?</sup>) <strong>rails_root</strong> </a>
    

    
  </span>
  
  
  
  
  

  
    <span class="summary_desc">Returns the root of the Rails application, if this is running in a Rails context.</span>
  
</li>

    
      <li class="public ">
  <span class="summary_signature">
    
      <a href="#rbx%3F-instance_method" title="#rbx? (instance method)">- (Boolean) <strong>rbx?</strong> </a>
    

    
  </span>
  
  
  
  
  

  
    <span class="summary_desc">Whether or not this is running on Rubinius.</span>
  
</li>

    
      <li class="public ">
  <span class="summary_signature">
    
      <a href="#restrict-instance_method" title="#restrict (instance method)">- (Numeric) <strong>restrict</strong>(value, range) </a>
    

    
  </span>
  
  
  
  
  

  
    <span class="summary_desc">Restricts a number to falling within a given range.</span>
  
</li>

    
      <li class="public ">
  <span class="summary_signature">
    
      <a href="#ruby1%3F-instance_method" title="#ruby1? (instance method)">- (Boolean) <strong>ruby1?</strong> </a>
    

    
  </span>
  
  
  
  
  

  
    <span class="summary_desc">Whether or not this is running under a Ruby version under 2.0.</span>
  
</li>

    
      <li class="public ">
  <span class="summary_signature">
    
      <a href="#ruby1_8%3F-instance_method" title="#ruby1_8? (instance method)">- (Boolean) <strong>ruby1_8?</strong> </a>
    

    
  </span>
  
  
  
  
  

  
    <span class="summary_desc">Whether or not this is running under Ruby 1.8 or lower.</span>
  
</li>

    
      <li class="public ">
  <span class="summary_signature">
    
      <a href="#ruby1_8_6%3F-instance_method" title="#ruby1_8_6? (instance method)">- (Boolean) <strong>ruby1_8_6?</strong> </a>
    

    
  </span>
  
  
  
  
  

  
    <span class="summary_desc">Whether or not this is running under Ruby 1.8.6 or lower.</span>
  
</li>

    
      <li class="public ">
  <span class="summary_signature">
    
      <a href="#sass_warn-instance_method" title="#sass_warn (instance method)">- <strong>sass_warn</strong>(msg) </a>
    

    
  </span>
  
  
  
  
  

  
    <span class="summary_desc">The same as <code>Kernel#warn</code>, but is silenced by <tt><a href="#silence_sass_warnings-instance_method" title="Sass::Util#silence_sass_warnings (method)">#silence_sass_warnings</a></tt>.</span>
  
</li>

    
      <li class="public ">
  <span class="summary_signature">
    
      <a href="#scope-instance_method" title="#scope (instance method)">- (String) <strong>scope</strong>(file) </a>
    

    
  </span>
  
  
  
  
  

  
    <span class="summary_desc">Returns the path of a file relative to the Sass root directory.</span>
  
</li>

    
      <li class="public ">
  <span class="summary_signature">
    
      <a href="#set_eql%3F-instance_method" title="#set_eql? (instance method)">- (Boolean) <strong>set_eql?</strong>(set1, set2) </a>
    

    
  </span>
  
  
  
  
  

  
    <span class="summary_desc">Tests the hash-equality of two sets in a cross-version manner.</span>
  
</li>

    
      <li class="public ">
  <span class="summary_signature">
    
      <a href="#set_hash-instance_method" title="#set_hash (instance method)">- (Fixnum) <strong>set_hash</strong>(set) </a>
    

    
  </span>
  
  
  
  
  

  
    <span class="summary_desc">Returns the hash code for a set in a cross-version manner.</span>
  
</li>

    
      <li class="public ">
  <span class="summary_signature">
    
      <a href="#silence_sass_warnings-instance_method" title="#silence_sass_warnings (instance method)">- <strong>silence_sass_warnings</strong> { ... }</a>
    

    
  </span>
  
  
  
  
  

  
    <span class="summary_desc">Silences all Sass warnings within a block.</span>
  
</li>

    
      <li class="public ">
  <span class="summary_signature">
    
      <a href="#silence_warnings-instance_method" title="#silence_warnings (instance method)">- <strong>silence_warnings</strong> { ... }</a>
    

    
  </span>
  
  
  
  
  

  
    <span class="summary_desc">Silence all output to STDERR within a block.</span>
  
</li>

    
      <li class="public ">
  <span class="summary_signature">
    
      <a href="#strip_string_array-instance_method" title="#strip_string_array (instance method)">- (Array) <strong>strip_string_array</strong>(arr) </a>
    

    
  </span>
  
  
  
  
  

  
    <span class="summary_desc">Destructively strips whitespace from the beginning and end of the first and last elements, respectively, in the array (if those elements are strings).</span>
  
</li>

    
      <li class="public ">
  <span class="summary_signature">
    
      <a href="#subsequence%3F-instance_method" title="#subsequence? (instance method)">- (Boolean) <strong>subsequence?</strong>(seq1, seq2) </a>
    

    
  </span>
  
  
  
  
  

  
    <span class="summary_desc">Returns whether or not <code>seq1</code> is a subsequence of <code>seq2</code>.</span>
  
</li>

    
      <li class="public ">
  <span class="summary_signature">
    
      <a href="#substitute-instance_method" title="#substitute (instance method)">- <strong>substitute</strong>(ary, from, to) </a>
    

    
  </span>
  
  
  
  
  

  
    <span class="summary_desc">Substitutes a sub-array of one array with another sub-array.</span>
  
</li>

    
      <li class="public ">
  <span class="summary_signature">
    
      <a href="#to_hash-instance_method" title="#to_hash (instance method)">- (Hash) <strong>to_hash</strong>(arr) </a>
    

    
  </span>
  
  
  
  
  

  
    <span class="summary_desc">Converts an array of <code>[key, value]</code> pairs to a hash.</span>
  
</li>

    
      <li class="public ">
  <span class="summary_signature">
    
      <a href="#undefined_conversion_error_char-instance_method" title="#undefined_conversion_error_char (instance method)">- (String) <strong>undefined_conversion_error_char</strong>(e) </a>
    

    
  </span>
  
  
  
  
  

  
    <span class="summary_desc">Returns a string description of the character that caused an <code>Encoding::UndefinedConversionError</code>.</span>
  
</li>

    
      <li class="public ">
  <span class="summary_signature">
    
      <a href="#version_geq-instance_method" title="#version_geq (instance method)">- (Boolean) <strong>version_geq</strong>(v1, v2) </a>
    

    
  </span>
  
  
  
  
  

  
    <span class="summary_desc">Returns whether one version string represents the same or a more recent version than another.</span>
  
</li>

    
      <li class="public ">
  <span class="summary_signature">
    
      <a href="#version_gt-instance_method" title="#version_gt (instance method)">- (Boolean) <strong>version_gt</strong>(v1, v2) </a>
    

    
  </span>
  
  
  
  
  

  
    <span class="summary_desc">Returns whether one version string represents a more recent version than another.</span>
  
</li>

    
      <li class="public ">
  <span class="summary_signature">
    
      <a href="#windows%3F-instance_method" title="#windows? (instance method)">- (Boolean) <strong>windows?</strong> </a>
    

    
  </span>
  
  
  
  
  

  
    <span class="summary_desc">Whether or not this is running on Windows.</span>
  
</li>

    
      <li class="public ">
  <span class="summary_signature">
    
      <a href="#with_extracted_values-instance_method" title="#with_extracted_values (instance method)">- (Array) <strong>with_extracted_values</strong>(arr) {|str| ... }</a>
    

    
  </span>
  
  
  
  
  

  
    <span class="summary_desc">Allows modifications to be performed on the string form of an array containing both strings and non-strings.</span>
  
</li>

    
  </ul>


  <div id="instance_method_details" class="method_details_list">
    <h2>Instance Method Details</h2>
    
    
      <div class="method_details first">
  <p class="signature first" id="abstract-instance_method">
  
    - <strong>abstract</strong>(obj) 
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>Throws a NotImplementedError for an abstract method.</p>

  </div>
</div>
<div class="tags">
  <h3>Parameters:</h3>
<ul class="param">
  
    <li>
      
        <span class='type'>(<tt>Object</tt>)</span>
      
      
        <span class='name'>obj</span>
      
      
      
        &mdash;
        <code>self</code>
      
    </li>
  
</ul>
<h3>Raises:</h3>
<ul class="raise">
  
    <li>
      
        <span class='type'>(<tt>NotImplementedError</tt>)</span>
      
      
      
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


380
381
382</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File '/var/www/sass-pages/.sass/lib/sass/util.rb', line 380</span>

def abstract(obj)
  raise NotImplementedError.new("#{obj.class} must implement ##{caller_info[2]}")
end</pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="ap_geq?-instance_method">
  
    - (<tt>Boolean</tt>) <strong>ap_geq?</strong>(version) 
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>Returns whether this environment is using ActionPack of a version greater than or equal to that specified.</p>

  </div>
</div>
<div class="tags">
  <h3>Parameters:</h3>
<ul class="param">
  
    <li>
      
        <span class='type'>(<tt>String</tt>)</span>
      
      
        <span class='name'>version</span>
      
      
      
        &mdash;
        The string version number to check against. Should be greater than or equal to Rails 3, because otherwise ActionPack::VERSION isn&#8217;t autoloaded
      
    </li>
  
</ul>
<h3>Returns:</h3>
<ul class="return">
  
    <li>
      
        <span class='type'>(<tt>Boolean</tt>)</span>
      
      
      
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


455
456
457
458
459
460
461</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File '/var/www/sass-pages/.sass/lib/sass/util.rb', line 455</span>

def ap_geq?(version)
  # The ActionPack module is always loaded automatically in Rails >= 3
  return false unless defined?(ActionPack) && defined?(ActionPack::VERSION) &&
    defined?(ActionPack::VERSION::STRING)

  version_geq(ActionPack::VERSION::STRING, version)
end</pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="ap_geq_3?-instance_method">
  
    - (<tt>Boolean</tt>) <strong>ap_geq_3?</strong> 
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>Returns whether this environment is using ActionPack version 3.0.0 or greater.</p>

  </div>
</div>
<div class="tags">
  <h3>Returns:</h3>
<ul class="return">
  
    <li>
      
        <span class='type'>(<tt>Boolean</tt>)</span>
      
      
      
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


444
445
446</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File '/var/www/sass-pages/.sass/lib/sass/util.rb', line 444</span>

def ap_geq_3?
  ap_geq?("3.0.0.beta1")
end</pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="array_minus-instance_method">
  
    - (<tt>Array</tt>) <strong>array_minus</strong>(minuend, subtrahend) 
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>Returns a sub-array of <code>minuend</code> containing only elements that are also in <code>subtrahend</code>. Ensures that the return value has the same order as <code>minuend</code>, even on Rubinius where that&#8217;s not guaranteed by <tt>Array#-</tt>.</p>

  </div>
</div>
<div class="tags">
  <h3>Parameters:</h3>
<ul class="param">
  
    <li>
      
        <span class='type'>(<tt>Array</tt>)</span>
      
      
        <span class='name'>minuend</span>
      
      
      
    </li>
  
    <li>
      
        <span class='type'>(<tt>Array</tt>)</span>
      
      
        <span class='name'>subtrahend</span>
      
      
      
    </li>
  
</ul>
<h3>Returns:</h3>
<ul class="return">
  
    <li>
      
        <span class='type'>(<tt>Array</tt>)</span>
      
      
      
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


266
267
268
269
270</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File '/var/www/sass-pages/.sass/lib/sass/util.rb', line 266</span>

def array_minus(minuend, subtrahend)
  return minuend - subtrahend unless rbx?
  set = Set.new(minuend) - subtrahend
  minuend.select {|e| set.include?(e)}
end</pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="av_template_class-instance_method">
  
    - <strong>av_template_class</strong>(name) 
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>Returns an ActionView::Template* class. In pre-3.0 versions of Rails, most of these classes were of the form <code>ActionView::TemplateFoo</code>, while afterwards they were of the form <code>ActionView;:Template::Foo</code>.</p>

  </div>
</div>
<div class="tags">
  <h3>Parameters:</h3>
<ul class="param">
  
    <li>
      
        <span class='type'>(<tt>#to_s</tt>)</span>
      
      
        <span class='name'>name</span>
      
      
      
        &mdash;
        The name of the class to get. For example, <code>:Error</code> will return <code>ActionView::TemplateError</code> or <code>ActionView::Template::Error</code>.
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


471
472
473
474</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File '/var/www/sass-pages/.sass/lib/sass/util.rb', line 471</span>

def av_template_class(name)
  return ActionView.const_get("Template#{name}") if ActionView.const_defined?("Template#{name}")
  return ActionView::Template.const_get(name.to_s)
end</pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="caller_info-instance_method">
  
    - (<tt>[String, Fixnum, (String, nil)]</tt>) <strong>caller_info</strong>(entry = nil) 
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>Returns information about the caller of the previous method.</p>

  </div>
</div>
<div class="tags">
  <h3>Parameters:</h3>
<ul class="param">
  
    <li>
      
        <span class='type'>(<tt>String</tt>)</span>
      
      
        <span class='name'>entry</span>
      
      
        <em class="default">(defaults to: <tt>nil</tt>)</em>
      
      
        &mdash;
        An entry in the <code>#caller</code> list, or a similarly formatted string
      
    </li>
  
</ul>
<h3>Returns:</h3>
<ul class="return">
  
    <li>
      
        <span class='type'>(<tt>[String, Fixnum, (String, nil)]</tt>)</span>
      
      
      
      
        &mdash;
        An array containing the filename, line, and method name of the caller. The method name may be nil
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


328
329
330
331
332
333
334
335
336</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File '/var/www/sass-pages/.sass/lib/sass/util.rb', line 328</span>

def caller_info(entry = nil)
  # JRuby evaluates `caller` incorrectly when it's in an actual default argument.
  entry ||= caller[1]
  info = entry.scan(/^(.*?):(-?.*?)(?::.*`(.+)')?$/).first
  info[1] = info[1].to_i
  # This is added by Rubinius to designate a block, but we don't care about it.
  info[2].sub!(/ \{\}\Z/, '') if info[2]
  info
end</pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="check_encoding-instance_method">
  
    - (<tt>String</tt>) <strong>check_encoding</strong>(str) {|msg| ... }
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>Checks that the encoding of a string is valid in Ruby 1.9 and cleans up potential encoding gotchas like the UTF-8 BOM. If it&#8217;s not, yields an error string describing the invalid character and the line on which it occurrs.</p>

  </div>
</div>
<div class="tags">
  <h3>Parameters:</h3>
<ul class="param">
  
    <li>
      
        <span class='type'>(<tt>String</tt>)</span>
      
      
        <span class='name'>str</span>
      
      
      
        &mdash;
        The string of which to check the encoding
      
    </li>
  
</ul>
<h3>Yields:</h3>
<ul class="yield">
  
    <li>
      
        <span class='type'>(<tt>msg</tt>)</span>
      
      
      
      
        &mdash;
        A block in which an encoding error can be raised. Only yields if there is an encoding error
      
    </li>
  
</ul>
<h3>Yield Parameters:</h3>
<ul class="yieldparam">
  
    <li>
      
        <span class='type'>(<tt>String</tt>)</span>
      
      
        <span class='name'>msg</span>
      
      
      
        &mdash;
        The error message to be raised
      
    </li>
  
</ul>
<h3>Returns:</h3>
<ul class="return">
  
    <li>
      
        <span class='type'>(<tt>String</tt>)</span>
      
      
      
      
        &mdash;
        <code>str</code>, potentially with encoding gotchas like BOMs removed
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File '/var/www/sass-pages/.sass/lib/sass/util.rb', line 585</span>

def check_encoding(str)
  if ruby1_8?
    return str.gsub(/\A\xEF\xBB\xBF/, '') # Get rid of the UTF-8 BOM
  elsif str.valid_encoding?
    # Get rid of the Unicode BOM if possible
    if str.encoding.name =~ /^UTF-(8|16|32)(BE|LE)?$/
      return str.gsub(Regexp.new("\\A\uFEFF".encode(str.encoding.name)), '')
    else
      return str
    end
  end

  encoding = str.encoding
  newlines = Regexp.new("\r\n|\r|\n".encode(encoding).force_encoding("binary"))
  str.force_encoding("binary").split(newlines).each_with_index do |line, i|
    begin
      line.encode(encoding)
    rescue Encoding::UndefinedConversionError => e
      yield <<MSG.rstrip, i + 1
Invalid #{encoding.name} character #{undefined_conversion_error_char(e)}
MSG
    end
  end
  return str
end</pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="check_range-instance_method">
  
    - (<tt>Numeric</tt>) <strong>check_range</strong>(name, range, value, unit = '') 
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>Asserts that <code>value</code> falls within <code>range</code> (inclusive), leaving room for slight floating-point errors.</p>

  </div>
</div>
<div class="tags">
  <h3>Parameters:</h3>
<ul class="param">
  
    <li>
      
        <span class='type'>(<tt>String</tt>)</span>
      
      
        <span class='name'>name</span>
      
      
      
        &mdash;
        The name of the value. Used in the error message.
      
    </li>
  
    <li>
      
        <span class='type'>(<tt>Range</tt>)</span>
      
      
        <span class='name'>range</span>
      
      
      
        &mdash;
        The allowed range of values.
      
    </li>
  
    <li>
      
        <span class='type'>(<tt>Numeric</tt>, <tt><a href="Number.html" tppabs="http://sass-lang.com/docs/yardoc/Sass/Script/Number.html" title="Sass::Script::Number (class)">Sass::Script::Number</a></tt>)</span>
      
      
        <span class='name'>value</span>
      
      
      
        &mdash;
        The value to check.
      
    </li>
  
    <li>
      
        <span class='type'>(<tt>String</tt>)</span>
      
      
        <span class='name'>unit</span>
      
      
        <em class="default">(defaults to: <tt>''</tt>)</em>
      
      
        &mdash;
        The unit of the value. Used in error reporting.
      
    </li>
  
</ul>
<h3>Returns:</h3>
<ul class="return">
  
    <li>
      
        <span class='type'>(<tt>Numeric</tt>)</span>
      
      
      
      
        &mdash;
        <code>value</code> adjusted to fall within range, if it was outside by a floating-point margin.
      
    </li>
  
</ul>
<h3>Raises:</h3>
<ul class="raise">
  
    <li>
      
        <span class='type'>(<tt>ArgumentError</tt>)</span>
      
      
      
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


295
296
297
298
299
300
301
302
303
304</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File '/var/www/sass-pages/.sass/lib/sass/util.rb', line 295</span>

def check_range(name, range, value, unit='')
  grace = (-0.00001..0.00001)
  str = value.to_s
  value = value.value if value.is_a?(Sass::Script::Number)
  return value if range.include?(value)
  return range.first if grace.include?(value - range.first)
  return range.last if grace.include?(value - range.last)
  raise ArgumentError.new(
    "#{name} #{str} must be between #{range.first}#{unit} and #{range.last}#{unit}")
end</pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="check_sass_encoding-instance_method">
  
    - (<tt>(String, Encoding)</tt>) <strong>check_sass_encoding</strong>(str, &amp;block) {|msg| ... }
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>Like <tt><a href="#check_encoding-instance_method" title="Sass::Util#check_encoding (method)">#check_encoding</a></tt>, but also checks for a <code>@charset</code> declaration at the beginning of the file and uses that encoding if it exists.</p>

<p>The Sass encoding rules are simple. If a <code>@charset</code> declaration exists, we assume that that&#8217;s the original encoding of the document. Otherwise, we use whatever encoding Ruby has. Then we convert that to UTF-8 to process internally. The UTF-8 end result is what&#8217;s returned by this method.</p>

  </div>
</div>
<div class="tags">
  <h3>Parameters:</h3>
<ul class="param">
  
    <li>
      
        <span class='type'>(<tt>String</tt>)</span>
      
      
        <span class='name'>str</span>
      
      
      
        &mdash;
        The string of which to check the encoding
      
    </li>
  
</ul>
<h3>Yields:</h3>
<ul class="yield">
  
    <li>
      
        <span class='type'>(<tt>msg</tt>)</span>
      
      
      
      
        &mdash;
        A block in which an encoding error can be raised. Only yields if there is an encoding error
      
    </li>
  
</ul>
<h3>Yield Parameters:</h3>
<ul class="yieldparam">
  
    <li>
      
        <span class='type'>(<tt>String</tt>)</span>
      
      
        <span class='name'>msg</span>
      
      
      
        &mdash;
        The error message to be raised
      
    </li>
  
</ul>
<h3>Returns:</h3>
<ul class="return">
  
    <li>
      
        <span class='type'>(<tt>(String, Encoding)</tt>)</span>
      
      
      
      
        &mdash;
        The original string encoded as UTF-8, and the source encoding of the string (or <code>nil</code> under Ruby 1.8)
      
    </li>
  
</ul>
<h3>Raises:</h3>
<ul class="raise">
  
    <li>
      
        <span class='type'>(<tt>Encoding::UndefinedConversionError</tt>)</span>
      
      
      
      
        &mdash;
        if the source encoding cannot be converted to UTF-8
      
    </li>
  
    <li>
      
        <span class='type'>(<tt>ArgumentError</tt>)</span>
      
      
      
      
        &mdash;
        if the document uses an unknown encoding with <code>@charset</code>
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File '/var/www/sass-pages/.sass/lib/sass/util.rb', line 630</span>

def check_sass_encoding(str, &block)
  return check_encoding(str, &block), nil if ruby1_8?
  # We allow any printable ASCII characters but double quotes in the charset decl
  bin = str.dup.force_encoding("BINARY")
  encoding = Sass::Util::ENCODINGS_TO_CHECK.find do |enc|
    re = Sass::Util::CHARSET_REGEXPS[enc]
    re && bin =~ re
  end
  charset, bom = $1, $2
  if charset
    charset = charset.force_encoding(encoding).encode("UTF-8")
    if endianness = encoding[/[BL]E$/]
      begin
        Encoding.find(charset + endianness)
        charset << endianness
      rescue ArgumentError # Encoding charset + endianness doesn't exist
      end
    end
    str.force_encoding(charset)
  elsif bom
    str.force_encoding(encoding)
  end

  str = check_encoding(str, &block)
  return str.encode("UTF-8"), str.encoding
end</pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="destructure-instance_method">
  
    - (<tt>Object</tt>) <strong>destructure</strong>(val) 
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>Prepare a value for a destructuring assignment (e.g. <code>a, b =
val</code>). This works around a performance bug when using ActiveSupport, and only needs to be called when <code>val</code> is likely to be <code>nil</code> reasonably often.</p>

<p>See <a href="javascript:if(confirm(%27http://redmine.ruby-lang.org/issues/4917  \n\nThis file was not retrieved by Teleport Pro, because it is addressed on a domain or path outside the boundaries set for its Starting Address.  \n\nDo you want to open it from the server?%27))window.location=%27http://redmine.ruby-lang.org/issues/4917%27" tppabs="http://redmine.ruby-lang.org/issues/4917">this bug report</a>.</p>

  </div>
</div>
<div class="tags">
  <h3>Parameters:</h3>
<ul class="param">
  
    <li>
      
        <span class='type'>(<tt>Object</tt>)</span>
      
      
        <span class='name'>val</span>
      
      
      
    </li>
  
</ul>
<h3>Returns:</h3>
<ul class="return">
  
    <li>
      
        <span class='type'>(<tt>Object</tt>)</span>
      
      
      
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


530
531
532</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File '/var/www/sass-pages/.sass/lib/sass/util.rb', line 530</span>

def destructure(val)
  val || []
end</pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="enum_cons-instance_method">
  
    - (<tt>Enumerator</tt>) <strong>enum_cons</strong>(enum, n) 
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>A version of <code>Enumerable#enum_cons</code> that works in Ruby 1.8 and 1.9.</p>

  </div>
</div>
<div class="tags">
  <h3>Parameters:</h3>
<ul class="param">
  
    <li>
      
        <span class='type'>(<tt>Enumerable</tt>)</span>
      
      
        <span class='name'>enum</span>
      
      
      
        &mdash;
        The enumerable to get the enumerator for
      
    </li>
  
    <li>
      
        <span class='type'>(<tt>Fixnum</tt>)</span>
      
      
        <span class='name'>n</span>
      
      
      
        &mdash;
        The size of each cons
      
    </li>
  
</ul>
<h3>Returns:</h3>
<ul class="return">
  
    <li>
      
        <span class='type'>(<tt>Enumerator</tt>)</span>
      
      
      
      
        &mdash;
        The consed enumerator
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


717
718
719</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File '/var/www/sass-pages/.sass/lib/sass/util.rb', line 717</span>

def enum_cons(enum, n)
  ruby1_8? ? enum.enum_cons(n) : enum.each_cons(n)
end</pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="enum_slice-instance_method">
  
    - (<tt>Enumerator</tt>) <strong>enum_slice</strong>(enum, n) 
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>A version of <code>Enumerable#enum_slice</code> that works in Ruby 1.8 and 1.9.</p>

  </div>
</div>
<div class="tags">
  <h3>Parameters:</h3>
<ul class="param">
  
    <li>
      
        <span class='type'>(<tt>Enumerable</tt>)</span>
      
      
        <span class='name'>enum</span>
      
      
      
        &mdash;
        The enumerable to get the enumerator for
      
    </li>
  
    <li>
      
        <span class='type'>(<tt>Fixnum</tt>)</span>
      
      
        <span class='name'>n</span>
      
      
      
        &mdash;
        The size of each slice
      
    </li>
  
</ul>
<h3>Returns:</h3>
<ul class="return">
  
    <li>
      
        <span class='type'>(<tt>Enumerator</tt>)</span>
      
      
      
      
        &mdash;
        The consed enumerator
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


726
727
728</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File '/var/www/sass-pages/.sass/lib/sass/util.rb', line 726</span>

def enum_slice(enum, n)
  ruby1_8? ? enum.enum_slice(n) : enum.each_slice(n)
end</pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="enum_with_index-instance_method">
  
    - (<tt>Enumerator</tt>) <strong>enum_with_index</strong>(enum) 
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>A version of <code>Enumerable#enum_with_index</code> that works in Ruby 1.8 and 1.9.</p>

  </div>
</div>
<div class="tags">
  <h3>Parameters:</h3>
<ul class="param">
  
    <li>
      
        <span class='type'>(<tt>Enumerable</tt>)</span>
      
      
        <span class='name'>enum</span>
      
      
      
        &mdash;
        The enumerable to get the enumerator for
      
    </li>
  
</ul>
<h3>Returns:</h3>
<ul class="return">
  
    <li>
      
        <span class='type'>(<tt>Enumerator</tt>)</span>
      
      
      
      
        &mdash;
        The with-index enumerator
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


708
709
710</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File '/var/www/sass-pages/.sass/lib/sass/util.rb', line 708</span>

def enum_with_index(enum)
  ruby1_8? ? enum.enum_with_index : enum.each_with_index
end</pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="extract!-instance_method">
  
    - (<tt>Array</tt>) <strong>extract!</strong>(array) {|el| ... }
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>Destructively removes all elements from an array that match a block, and returns the removed elements.</p>

  </div>
</div>
<div class="tags">
  <h3>Parameters:</h3>
<ul class="param">
  
    <li>
      
        <span class='type'>(<tt>Array</tt>)</span>
      
      
        <span class='name'>array</span>
      
      
      
        &mdash;
        The array from which to remove elements.
      
    </li>
  
</ul>
<h3>Yields:</h3>
<ul class="yield">
  
    <li>
      
        <span class='type'>(<tt>el</tt>)</span>
      
      
      
      
        &mdash;
        Called for each element.
      
    </li>
  
</ul>
<h3>Yield Parameters:</h3>
<ul class="yieldparam">
  
    <li>
      
        <span class='type'>(<tt>*</tt>)</span>
      
      
        <span class='name'>el</span>
      
      
      
        &mdash;
        The element to test.
      
    </li>
  
</ul>
<h3>Yield Returns:</h3>
<ul class="yieldreturn">
  
    <li>
      
        <span class='type'>(<tt>Boolean</tt>)</span>
      
      
      
      
        &mdash;
        Whether or not to extract the element.
      
    </li>
  
</ul>
<h3>Returns:</h3>
<ul class="return">
  
    <li>
      
        <span class='type'>(<tt>Array</tt>)</span>
      
      
      
      
        &mdash;
        The extracted elements.
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


738
739
740
741
742
743
744
745
746</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File '/var/www/sass-pages/.sass/lib/sass/util.rb', line 738</span>

def extract!(array)
  out = []
  array.reject! do |e|
    next false unless yield e
    out << e
    true
  end
  out
end</pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="extract_values-instance_method">
  
    - (<tt>(String, Array)</tt>) <strong>extract_values</strong>(arr) 
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>Extracts the non-string vlaues from an array containing both strings and non-strings. These values are replaced with escape sequences. This can be undone using <tt><a href="#inject_values-instance_method" title="Sass::Util#inject_values (method)">#inject_values</a></tt>.</p>

<p>This is useful e.g. when we want to do string manipulation on an interpolated string.</p>

<p>The precise format of the resulting string is not guaranteed. However, it is guaranteed that newlines and whitespace won&#8217;t be affected.</p>

  </div>
</div>
<div class="tags">
  <h3>Parameters:</h3>
<ul class="param">
  
    <li>
      
        <span class='type'>(<tt>Array</tt>)</span>
      
      
        <span class='name'>arr</span>
      
      
      
        &mdash;
        The array from which values are extracted.
      
    </li>
  
</ul>
<h3>Returns:</h3>
<ul class="return">
  
    <li>
      
        <span class='type'>(<tt>(String, Array)</tt>)</span>
      
      
      
      
        &mdash;
        The resulting string, and an array of extracted values.
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


813
814
815
816
817
818
819
820</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File '/var/www/sass-pages/.sass/lib/sass/util.rb', line 813</span>

def extract_values(arr)
  values = []
  return arr.map do |e|
    next e.gsub('{', '{{') if e.is_a?(String)
    values << e
    next "{#{values.count - 1}}"
  end.join, values
end</pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="flatten-instance_method">
  
    - (<tt>Array</tt>) <strong>flatten</strong>(arr, n) 
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>Flattens the first <code>n</code> nested arrays in a cross-version manner.</p>

  </div>
</div>
<div class="tags">
  <h3>Parameters:</h3>
<ul class="param">
  
    <li>
      
        <span class='type'>(<tt>Array</tt>)</span>
      
      
        <span class='name'>arr</span>
      
      
      
        &mdash;
        The array to flatten
      
    </li>
  
    <li>
      
        <span class='type'>(<tt>Fixnum</tt>)</span>
      
      
        <span class='name'>n</span>
      
      
      
        &mdash;
        The number of levels to flatten
      
    </li>
  
</ul>
<h3>Returns:</h3>
<ul class="return">
  
    <li>
      
        <span class='type'>(<tt>Array</tt>)</span>
      
      
      
      
        &mdash;
        The flattened array
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


761
762
763
764
765</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File '/var/www/sass-pages/.sass/lib/sass/util.rb', line 761</span>

def flatten(arr, n)
  return arr.flatten(n) unless ruby1_8_6?
  return arr if n == 0
  arr.inject([]) {|res, e| e.is_a?(Array) ? res.concat(flatten(e, n - 1)) : res << e}
end</pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="glob-instance_method">
  
    - <strong>glob</strong>(path, &amp;block) 
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>Like <code>Dir.glob</code>, but works with backslash-separated paths on Windows.</p>

  </div>
</div>
<div class="tags">
  <h3>Parameters:</h3>
<ul class="param">
  
    <li>
      
        <span class='type'>(<tt>String</tt>)</span>
      
      
        <span class='name'>path</span>
      
      
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


516
517
518
519</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File '/var/www/sass-pages/.sass/lib/sass/util.rb', line 516</span>

def glob(path, &block)
  path = path.gsub('\\', '/') if windows?
  Dir.glob(path, &block)
end</pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="group_by_to_a-instance_method">
  
    - (<tt>Array&lt;[Object, Array]&gt;</tt>) <strong>group_by_to_a</strong>(enum, &amp;block) 
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>Performs the equivalent of <code>enum.group_by.to_a</code>, but with a guaranteed order. Unlike <span>#hash_to_a</span>, the resulting order isn&#8217;t sorted key order; instead, it&#8217;s the same order as <code>#group_by</code> has under Ruby 1.9 (key appearance order).</p>

  </div>
</div>
<div class="tags">
  <h3>Parameters:</h3>
<ul class="param">
  
    <li>
      
        <span class='type'>(<tt>Enumerable</tt>)</span>
      
      
        <span class='name'>enum</span>
      
      
      
    </li>
  
</ul>
<h3>Returns:</h3>
<ul class="return">
  
    <li>
      
        <span class='type'>(<tt>Array&lt;[Object, Array]&gt;</tt>)</span>
      
      
      
      
        &mdash;
        An array of pairs.
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


243
244
245
246
247
248
249
250
251
252
253
254
255
256
257</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File '/var/www/sass-pages/.sass/lib/sass/util.rb', line 243</span>

def group_by_to_a(enum, &block)
  return enum.group_by(&block).to_a unless ruby1_8?
  order = {}
  arr = []
  enum.group_by do |e|
    res = block[e]
    unless order.include?(res)
      order[res] = order.size
    end
    res
  end.each do |key, vals|
    arr[order[key]] = [key, vals]
  end
  arr
end</pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="has?-instance_method">
  
    - (<tt>Boolean</tt>) <strong>has?</strong>(attr, klass, method) 
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>Checks to see if a class has a given method. For example:</p>

<pre class="code">Sass::Util.has?(:public_instance_method, String, :gsub) #=&gt; true</pre>

<p>Method collections like <code>Class#instance_methods</code> return strings in Ruby 1.8 and symbols in Ruby 1.9 and on, so this handles checking for them in a compatible way.</p>

  </div>
</div>
<div class="tags">
  <h3>Parameters:</h3>
<ul class="param">
  
    <li>
      
        <span class='type'>(<tt>#to_s</tt>)</span>
      
      
        <span class='name'>attr</span>
      
      
      
        &mdash;
        The (singular) name of the method-collection method (e.g. <code>:instance_methods</code>, <code>:private_methods</code>)
      
    </li>
  
    <li>
      
        <span class='type'>(<tt>Module</tt>)</span>
      
      
        <span class='name'>klass</span>
      
      
      
        &mdash;
        The class to check the methods of which to check
      
    </li>
  
    <li>
      
        <span class='type'>(<tt>String</tt>, <tt>Symbol</tt>)</span>
      
      
        <span class='name'>method</span>
      
      
      
        &mdash;
        The name of the method do check for
      
    </li>
  
</ul>
<h3>Returns:</h3>
<ul class="return">
  
    <li>
      
        <span class='type'>(<tt>Boolean</tt>)</span>
      
      
      
      
        &mdash;
        Whether or not the given collection has the given method
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


700
701
702</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File '/var/www/sass-pages/.sass/lib/sass/util.rb', line 700</span>

def has?(attr, klass, method)
  klass.send("#{attr}s").include?(ruby1_8? ? method.to_s : method.to_sym)
end</pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="hash_to_a-instance_method">
  
    - (<tt>Array</tt>) <strong>hash_to_a</strong>(hash) 
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>Converts a Hash to an Array. This is usually identical to <code>Hash#to_a</code>, with the following exceptions:</p>

<ul>
<li>In Ruby 1.8, <code>Hash#to_a</code> is not deterministically ordered, but this is.</li>

<li>In Ruby 1.9 when running tests, this is ordered in the same way it would be under Ruby 1.8 (sorted key order rather than insertion order).</li>
</ul>

  </div>
</div>
<div class="tags">
  <h3>Parameters:</h3>
<ul class="param">
  
    <li>
      
        <span class='type'>(<tt>Hash</tt>)</span>
      
      
        <span class='name'>hash</span>
      
      
      
    </li>
  
</ul>
<h3>Returns:</h3>
<ul class="return">
  
    <li>
      
        <span class='type'>(<tt>Array</tt>)</span>
      
      
      
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


231
232
233
234</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File '/var/www/sass-pages/.sass/lib/sass/util.rb', line 231</span>

def hash_to_a(hash)
  return hash.to_a unless ruby1_8? || defined?(Test::Unit)
  return hash.sort_by {|k, v| k}
end</pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="inject_values-instance_method">
  
    - (<tt>Array</tt>) <strong>inject_values</strong>(str, values) 
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>Undoes <tt><a href="#extract_values-instance_method" title="Sass::Util#extract_values (method)">#extract_values</a></tt> by transforming a string with escape sequences into an array of strings and non-string values.</p>

  </div>
</div>
<div class="tags">
  <h3>Parameters:</h3>
<ul class="param">
  
    <li>
      
        <span class='type'>(<tt>String</tt>)</span>
      
      
        <span class='name'>str</span>
      
      
      
        &mdash;
        The string with escape sequences.
      
    </li>
  
    <li>
      
        <span class='type'>(<tt>Array</tt>)</span>
      
      
        <span class='name'>values</span>
      
      
      
        &mdash;
        The array of values to inject.
      
    </li>
  
</ul>
<h3>Returns:</h3>
<ul class="return">
  
    <li>
      
        <span class='type'>(<tt>Array</tt>)</span>
      
      
      
      
        &mdash;
        The array of strings and values.
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


828
829
830
831
832
833
834
835
836</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File '/var/www/sass-pages/.sass/lib/sass/util.rb', line 828</span>

def inject_values(str, values)
  return [str.gsub('{{', '{')] if values.empty?
  # Add an extra { so that we process the tail end of the string
  result = (str + '{{').scan(/(.*?)(?:(\{\{)|\{(\d+)\})/m).map do |(pre, esc, n)|
    [pre, esc ? '{' : '', n ? values[n.to_i] : '']
  end.flatten(1)
  result[-2] = '' # Get rid of the extra {
  merge_adjacent_strings(result).reject {|s| s == ''}
end</pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="inspect_obj-instance_method">
  
    - (<tt>String</tt>) <strong>inspect_obj</strong>(obj) 
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>Like <code>Object#inspect</code>, but preserves non-ASCII characters rather than escaping them under Ruby 1.9.2. This is necessary so that the precompiled Haml template can be <code>#encode</code>d into <code>@options[:encoding]</code> before being evaluated.</p>

  </div>
</div>
<div class="tags">
  <h3>Parameters:</h3>
<ul class="param">
  
    <li>
      
        <span class='type'>(<tt>Object</tt>)</span>
      
      
        <span class='name'>obj</span>
      
      
      
    </li>
  
</ul>
<h3>Returns:</h3>
<ul class="return">
  
    <li>
      
        <span class='type'>(<tt>String</tt>)</span>
      
      
      
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


794
795
796
797
798
799</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File '/var/www/sass-pages/.sass/lib/sass/util.rb', line 794</span>

def inspect_obj(obj)
  return obj.inspect unless version_geq(::RUBY_VERSION, "1.9.2")
  return ':' + inspect_obj(obj.to_s) if obj.is_a?(Symbol)
  return obj.inspect unless obj.is_a?(String)
  '"' + obj.gsub(/[\x00-\x7F]+/) {|s| s.inspect[1...-1]} + '"'
end</pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="intersperse-instance_method">
  
    - (<tt>Array</tt>) <strong>intersperse</strong>(enum, val) 
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>Intersperses a value in an enumerable, as would be done with <code>Array#join</code> but without concatenating the array together afterwards.</p>

  </div>
</div>
<div class="tags">
  <h3>Parameters:</h3>
<ul class="param">
  
    <li>
      
        <span class='type'>(<tt>Enumerable</tt>)</span>
      
      
        <span class='name'>enum</span>
      
      
      
    </li>
  
    <li>
      
        <span class='type'></span>
      
      
        <span class='name'>val</span>
      
      
      
    </li>
  
</ul>
<h3>Returns:</h3>
<ul class="return">
  
    <li>
      
        <span class='type'>(<tt>Array</tt>)</span>
      
      
      
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


154
155
156</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File '/var/www/sass-pages/.sass/lib/sass/util.rb', line 154</span>

def intersperse(enum, val)
  enum.inject([]) {|a, e| a << e << val}[0...-1]
end</pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="ironruby?-instance_method">
  
    - (<tt>Boolean</tt>) <strong>ironruby?</strong> 
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>Whether or not this is running on IronRuby.</p>

  </div>
</div>
<div class="tags">
  <h3>Returns:</h3>
<ul class="return">
  
    <li>
      
        <span class='type'>(<tt>Boolean</tt>)</span>
      
      
      
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


488
489
490</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File '/var/www/sass-pages/.sass/lib/sass/util.rb', line 488</span>

def ironruby?
  RUBY_ENGINE == "ironruby"
end</pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="jruby1_6?-instance_method">
  
    - (<tt>Boolean</tt>) <strong>jruby1_6?</strong> 
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>Wehter or not this is running under JRuby 1.6 or lower.</p>

  </div>
</div>
<div class="tags">
  <h3>Returns:</h3>
<ul class="return">
  
    <li>
      
        <span class='type'>(<tt>Boolean</tt>)</span>
      
      
      
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


564
565
566</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File '/var/www/sass-pages/.sass/lib/sass/util.rb', line 564</span>

def jruby1_6?
  jruby? && jruby_version[0] == 1 && jruby_version[1] < 7
end</pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="jruby?-instance_method">
  
    - (<tt>Boolean</tt>) <strong>jruby?</strong> 
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>Whether or not this is running on JRuby.</p>

  </div>
</div>
<div class="tags">
  <h3>Returns:</h3>
<ul class="return">
  
    <li>
      
        <span class='type'>(<tt>Boolean</tt>)</span>
      
      
      
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


502
503
504</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File '/var/www/sass-pages/.sass/lib/sass/util.rb', line 502</span>

def jruby?
  RUBY_PLATFORM =~ /java/
end</pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="jruby_version-instance_method">
  
    - (<tt>Array&lt;Fixnum&gt;</tt>) <strong>jruby_version</strong> 
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>Returns an array of ints representing the JRuby version number.</p>

  </div>
</div>
<div class="tags">
  <h3>Returns:</h3>
<ul class="return">
  
    <li>
      
        <span class='type'>(<tt>Array&lt;Fixnum&gt;</tt>)</span>
      
      
      
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


509
510
511</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File '/var/www/sass-pages/.sass/lib/sass/util.rb', line 509</span>

def jruby_version
  $jruby_version ||= ::JRUBY_VERSION.split(".").map {|s| s.to_i}
end</pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="lcs-instance_method">
  
    - (<tt>Array</tt>) <strong>lcs</strong>(x, y, &amp;block) {|a, b| ... }
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>Computes a single longest common subsequence for <code>x</code> and <code>y</code>. If there are more than one longest common subsequences, the one returned is that which starts first in <code>x</code>.</p>

  </div>
</div>
<div class="tags">
  <h3>Parameters:</h3>
<ul class="param">
  
    <li>
      
        <span class='type'>(<tt>Array</tt>)</span>
      
      
        <span class='name'>x</span>
      
      
      
    </li>
  
    <li>
      
        <span class='type'>(<tt>Array</tt>)</span>
      
      
        <span class='name'>y</span>
      
      
      
    </li>
  
</ul>
<h3>Yields:</h3>
<ul class="yield">
  
    <li>
      
        <span class='type'>(<tt>a</tt>, <tt>b</tt>)</span>
      
      
      
      
        &mdash;
        An optional block to use in place of a check for equality between elements of <code>x</code> and <code>y</code>.
      
    </li>
  
</ul>
<h3>Yield Returns:</h3>
<ul class="yieldreturn">
  
    <li>
      
        <span class='type'>(<tt>Object</tt>, <tt>nil</tt>)</span>
      
      
      
      
        &mdash;
        If the two values register as equal, this will return the value to use in the LCS array.
      
    </li>
  
</ul>
<h3>Returns:</h3>
<ul class="return">
  
    <li>
      
        <span class='type'>(<tt>Array</tt>)</span>
      
      
      
      
        &mdash;
        The LCS
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


215
216
217
218
219
220</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File '/var/www/sass-pages/.sass/lib/sass/util.rb', line 215</span>

def lcs(x, y, &block)
  x = [nil, *x]
  y = [nil, *y]
  block ||= proc {|a, b| a == b && a}
  lcs_backtrace(lcs_table(x, y, &block), x, y, x.size-1, y.size-1, &block)
end</pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="macruby?-instance_method">
  
    - (<tt>Boolean</tt>) <strong>macruby?</strong> 
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>Whether or not this is running under MacRuby.</p>

  </div>
</div>
<div class="tags">
  <h3>Returns:</h3>
<ul class="return">
  
    <li>
      
        <span class='type'>(<tt>Boolean</tt>)</span>
      
      
      
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


571
572
573</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File '/var/www/sass-pages/.sass/lib/sass/util.rb', line 571</span>

def macruby?
  RUBY_ENGINE == 'macruby'
end</pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="map_hash-instance_method">
  
    - (<tt>Hash</tt>) <strong>map_hash</strong>(hash) {|key, value| ... }
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>Maps the key-value pairs of a hash according to a block.</p>

  </div>
</div>
<div class="tags">
  
  <div class="examples">
    <h3>Examples:</h3>
    
      <h4></h4>
      <pre class="example code">  map_hash({:foo => "bar", :baz => "bang"}) {|k, v| [k.to_s, v.to_sym]}
    #=> {"foo" => :bar, "baz" => :bang}</pre>
    
  </div>
<h3>Parameters:</h3>
<ul class="param">
  
    <li>
      
        <span class='type'>(<tt>Hash</tt>)</span>
      
      
        <span class='name'>hash</span>
      
      
      
        &mdash;
        The hash to map
      
    </li>
  
</ul>
<h3>Yields:</h3>
<ul class="yield">
  
    <li>
      
        <span class='type'>(<tt>key</tt>, <tt>value</tt>)</span>
      
      
      
      
        &mdash;
        A block in which the key-value pairs are transformed
      
    </li>
  
</ul>
<h3>Yield Parameters:</h3>
<ul class="yieldparam">
  
    <li>
      
        <span class='type'>(<tt>key</tt>)</span>
      
      
        <span class='name'>The</span>
      
      
      
        &mdash;
        hash key
      
    </li>
  
    <li>
      
        <span class='type'>(<tt>value</tt>)</span>
      
      
        <span class='name'>The</span>
      
      
      
        &mdash;
        hash value
      
    </li>
  
</ul>
<h3>Yield Returns:</h3>
<ul class="yieldreturn">
  
    <li>
      
        <span class='type'>(<tt>(Object, Object)</tt>)</span>
      
      
      
      
        &mdash;
        The new value for the <code>[key, value]</code> pair
      
    </li>
  
</ul>
<h3>Returns:</h3>
<ul class="return">
  
    <li>
      
        <span class='type'>(<tt>Hash</tt>)</span>
      
      
      
      
        &mdash;
        The mapped hash
      
    </li>
  
</ul>

  <h3>See Also:</h3>
  <ul class="see">
    
      <li><a href="#map_keys-instance_method" title="Sass::Util#map_keys (method)">#map_keys</a></li>
    
      <li><a href="#map_vals-instance_method" title="Sass::Util#map_vals (method)">#map_vals</a></li>
    
  </ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


88
89
90
91</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File '/var/www/sass-pages/.sass/lib/sass/util.rb', line 88</span>

def map_hash(hash)
  # Using &block here completely hoses performance on 1.8.
  to_hash(hash.map {|k, v| yield k, v})
end</pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="map_keys-instance_method">
  
    - (<tt>Hash</tt>) <strong>map_keys</strong>(hash) {|key| ... }
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>Maps the keys in a hash according to a block.</p>

  </div>
</div>
<div class="tags">
  
  <div class="examples">
    <h3>Examples:</h3>
    
      <h4></h4>
      <pre class="example code">  map_keys({:foo => "bar", :baz => "bang"}) {|k| k.to_s}
    #=> {"foo" => "bar", "baz" => "bang"}</pre>
    
  </div>
<h3>Parameters:</h3>
<ul class="param">
  
    <li>
      
        <span class='type'>(<tt>Hash</tt>)</span>
      
      
        <span class='name'>hash</span>
      
      
      
        &mdash;
        The hash to map
      
    </li>
  
</ul>
<h3>Yields:</h3>
<ul class="yield">
  
    <li>
      
        <span class='type'>(<tt>key</tt>)</span>
      
      
      
      
        &mdash;
        A block in which the keys are transformed
      
    </li>
  
</ul>
<h3>Yield Parameters:</h3>
<ul class="yieldparam">
  
    <li>
      
        <span class='type'>(<tt>Object</tt>)</span>
      
      
        <span class='name'>key</span>
      
      
      
        &mdash;
        The key that should be mapped
      
    </li>
  
</ul>
<h3>Yield Returns:</h3>
<ul class="yieldreturn">
  
    <li>
      
        <span class='type'>(<tt>Object</tt>)</span>
      
      
      
      
        &mdash;
        The new value for the key
      
    </li>
  
</ul>
<h3>Returns:</h3>
<ul class="return">
  
    <li>
      
        <span class='type'>(<tt>Hash</tt>)</span>
      
      
      
      
        &mdash;
        The mapped hash
      
    </li>
  
</ul>

  <h3>See Also:</h3>
  <ul class="see">
    
      <li><a href="#map_vals-instance_method" title="Sass::Util#map_vals (method)">#map_vals</a></li>
    
      <li><a href="#map_hash-instance_method" title="Sass::Util#map_hash (method)">#map_hash</a></li>
    
  </ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


55
56
57</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File '/var/www/sass-pages/.sass/lib/sass/util.rb', line 55</span>

def map_keys(hash)
  to_hash(hash.map {|k, v| [yield(k), v]})
end</pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="map_vals-instance_method">
  
    - (<tt>Hash</tt>) <strong>map_vals</strong>(hash) {|value| ... }
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>Maps the values in a hash according to a block.</p>

  </div>
</div>
<div class="tags">
  
  <div class="examples">
    <h3>Examples:</h3>
    
      <h4></h4>
      <pre class="example code">  map_values({:foo => "bar", :baz => "bang"}) {|v| v.to_sym}
    #=> {:foo => :bar, :baz => :bang}</pre>
    
  </div>
<h3>Parameters:</h3>
<ul class="param">
  
    <li>
      
        <span class='type'>(<tt>Hash</tt>)</span>
      
      
        <span class='name'>hash</span>
      
      
      
        &mdash;
        The hash to map
      
    </li>
  
</ul>
<h3>Yields:</h3>
<ul class="yield">
  
    <li>
      
        <span class='type'>(<tt>value</tt>)</span>
      
      
      
      
        &mdash;
        A block in which the values are transformed
      
    </li>
  
</ul>
<h3>Yield Parameters:</h3>
<ul class="yieldparam">
  
    <li>
      
        <span class='type'>(<tt>Object</tt>)</span>
      
      
        <span class='name'>value</span>
      
      
      
        &mdash;
        The value that should be mapped
      
    </li>
  
</ul>
<h3>Yield Returns:</h3>
<ul class="yieldreturn">
  
    <li>
      
        <span class='type'>(<tt>Object</tt>)</span>
      
      
      
      
        &mdash;
        The new value for the value
      
    </li>
  
</ul>
<h3>Returns:</h3>
<ul class="return">
  
    <li>
      
        <span class='type'>(<tt>Hash</tt>)</span>
      
      
      
      
        &mdash;
        The mapped hash
      
    </li>
  
</ul>

  <h3>See Also:</h3>
  <ul class="see">
    
      <li><a href="#map_keys-instance_method" title="Sass::Util#map_keys (method)">#map_keys</a></li>
    
      <li><a href="#map_hash-instance_method" title="Sass::Util#map_hash (method)">#map_hash</a></li>
    
  </ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


71
72
73</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File '/var/www/sass-pages/.sass/lib/sass/util.rb', line 71</span>

def map_vals(hash)
  to_hash(hash.map {|k, v| [k, yield(v)]})
end</pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="merge_adjacent_strings-instance_method">
  
    - (<tt>Array</tt>) <strong>merge_adjacent_strings</strong>(arr) 
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>Concatenates all strings that are adjacent in an array, while leaving other elements as they are.</p>

  </div>
</div>
<div class="tags">
  
  <div class="examples">
    <h3>Examples:</h3>
    
      <h4></h4>
      <pre class="example code">  merge_adjacent_strings([1, "foo", "bar", 2, "baz"])
    #=> [1, "foobar", 2, "baz"]</pre>
    
  </div>
<h3>Parameters:</h3>
<ul class="param">
  
    <li>
      
        <span class='type'>(<tt>Array</tt>)</span>
      
      
        <span class='name'>arr</span>
      
      
      
    </li>
  
</ul>
<h3>Returns:</h3>
<ul class="return">
  
    <li>
      
        <span class='type'>(<tt>Array</tt>)</span>
      
      
      
      
        &mdash;
        The enumerable with strings merged
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File '/var/www/sass-pages/.sass/lib/sass/util.rb', line 131</span>

def merge_adjacent_strings(arr)
  # Optimize for the common case of one element
  return arr if arr.size < 2
  arr.inject([]) do |a, e|
    if e.is_a?(String)
      if a.last.is_a?(String)
        a.last << e
      else
        a << e.dup
      end
    else
      a << e
    end
    a
  end
end</pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="ord-instance_method">
  
    - (<tt>Fixnum</tt>) <strong>ord</strong>(c) 
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>Returns the ASCII code of the given character.</p>

  </div>
</div>
<div class="tags">
  <h3>Parameters:</h3>
<ul class="param">
  
    <li>
      
        <span class='type'>(<tt>String</tt>)</span>
      
      
        <span class='name'>c</span>
      
      
      
        &mdash;
        All characters but the first are ignored.
      
    </li>
  
</ul>
<h3>Returns:</h3>
<ul class="return">
  
    <li>
      
        <span class='type'>(<tt>Fixnum</tt>)</span>
      
      
      
      
        &mdash;
        The ASCII code of <code>c</code>.
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


752
753
754</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File '/var/www/sass-pages/.sass/lib/sass/util.rb', line 752</span>

def ord(c)
  ruby1_8? ? c[0] : c.ord
end</pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="paths-instance_method">
  
    - (<tt>Array&lt;Arrays&gt;</tt>) <strong>paths</strong>(arrs) 
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>Return an array of all possible paths through the given arrays.</p>

  </div>
</div>
<div class="tags">
  
  <div class="examples">
    <h3>Examples:</h3>
    
      <h4></h4>
      <pre class="example code">  paths([[1, 2], [3, 4], [5]]) #=>
    # [[1, 3, 5],
    #  [2, 3, 5],
    #  [1, 4, 5],
    #  [2, 4, 5]]</pre>
    
  </div>
<h3>Parameters:</h3>
<ul class="param">
  
    <li>
      
        <span class='type'>(<tt>Array&lt;Array&gt;</tt>)</span>
      
      
        <span class='name'>arrs</span>
      
      
      
    </li>
  
</ul>
<h3>Returns:</h3>
<ul class="return">
  
    <li>
      
        <span class='type'>(<tt>Array&lt;Arrays&gt;</tt>)</span>
      
      
      
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


198
199
200
201
202</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File '/var/www/sass-pages/.sass/lib/sass/util.rb', line 198</span>

def paths(arrs)
  arrs.inject([[]]) do |paths, arr|
    flatten(arr.map {|e| paths.map {|path| path + [e]}}, 1)
  end
end</pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="powerset-instance_method">
  
    - (<tt>Set&lt;Set&gt;</tt>) <strong>powerset</strong>(arr) 
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>Computes the powerset of the given array. This is the set of all subsets of the array.</p>

  </div>
</div>
<div class="tags">
  
  <div class="examples">
    <h3>Examples:</h3>
    
      <h4></h4>
      <pre class="example code">  powerset([1, 2, 3]) #=>
    Set[Set[], Set[1], Set[2], Set[3], Set[1, 2], Set[2, 3], Set[1, 3], Set[1, 2, 3]]</pre>
    
  </div>
<h3>Parameters:</h3>
<ul class="param">
  
    <li>
      
        <span class='type'>(<tt>Enumerable</tt>)</span>
      
      
        <span class='name'>arr</span>
      
      
      
    </li>
  
</ul>
<h3>Returns:</h3>
<ul class="return">
  
    <li>
      
        <span class='type'>(<tt>Set&lt;Set&gt;</tt>)</span>
      
      
      
      
        &mdash;
        The subsets of <code>arr</code>
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


101
102
103
104
105
106
107
108
109
110</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File '/var/www/sass-pages/.sass/lib/sass/util.rb', line 101</span>

def powerset(arr)
  arr.inject([Set.new].to_set) do |powerset, el|
    new_powerset = Set.new
    powerset.each do |subset|
      new_powerset << subset
      new_powerset << subset + [el]
    end
    new_powerset
  end
end</pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="rails_env-instance_method">
  
    - (<tt>String</tt><sup>?</sup>) <strong>rails_env</strong> 
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>Returns the environment of the Rails application, if this is running in a Rails context. Returns <code>nil</code> if no such environment is defined.</p>

  </div>
</div>
<div class="tags">
  <h3>Returns:</h3>
<ul class="return">
  
    <li>
      
        <span class='type'>(<tt>String</tt>, <tt>nil</tt>)</span>
      
      
      
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


434
435
436
437
438</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File '/var/www/sass-pages/.sass/lib/sass/util.rb', line 434</span>

def rails_env
  return ::Rails.env.to_s if defined?(::Rails.env)
  return RAILS_ENV.to_s if defined?(RAILS_ENV)
  return nil
end</pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="rails_root-instance_method">
  
    - (<tt>String</tt><sup>?</sup>) <strong>rails_root</strong> 
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>Returns the root of the Rails application, if this is running in a Rails context. Returns <code>nil</code> if no such root is defined.</p>

  </div>
</div>
<div class="tags">
  <h3>Returns:</h3>
<ul class="return">
  
    <li>
      
        <span class='type'>(<tt>String</tt>, <tt>nil</tt>)</span>
      
      
      
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


420
421
422
423
424
425
426
427</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File '/var/www/sass-pages/.sass/lib/sass/util.rb', line 420</span>

def rails_root
  if defined?(::Rails.root)
    return ::Rails.root.to_s if ::Rails.root
    raise "ERROR: Rails.root is nil!"
  end
  return RAILS_ROOT.to_s if defined?(RAILS_ROOT)
  return nil
end</pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="rbx?-instance_method">
  
    - (<tt>Boolean</tt>) <strong>rbx?</strong> 
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>Whether or not this is running on Rubinius.</p>

  </div>
</div>
<div class="tags">
  <h3>Returns:</h3>
<ul class="return">
  
    <li>
      
        <span class='type'>(<tt>Boolean</tt>)</span>
      
      
      
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


495
496
497</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File '/var/www/sass-pages/.sass/lib/sass/util.rb', line 495</span>

def rbx?
  RUBY_ENGINE == "rbx"
end</pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="restrict-instance_method">
  
    - (<tt>Numeric</tt>) <strong>restrict</strong>(value, range) 
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>Restricts a number to falling within a given range. Returns the number if it falls within the range, or the closest value in the range if it doesn&#8217;t.</p>

  </div>
</div>
<div class="tags">
  <h3>Parameters:</h3>
<ul class="param">
  
    <li>
      
        <span class='type'>(<tt>Numeric</tt>)</span>
      
      
        <span class='name'>value</span>
      
      
      
    </li>
  
    <li>
      
        <span class='type'>(<tt>Range&lt;Numeric&gt;</tt>)</span>
      
      
        <span class='name'>range</span>
      
      
      
    </li>
  
</ul>
<h3>Returns:</h3>
<ul class="return">
  
    <li>
      
        <span class='type'>(<tt>Numeric</tt>)</span>
      
      
      
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


119
120
121</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File '/var/www/sass-pages/.sass/lib/sass/util.rb', line 119</span>

def restrict(value, range)
  [[value, range.first].max, range.last].min
end</pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="ruby1?-instance_method">
  
    - (<tt>Boolean</tt>) <strong>ruby1?</strong> 
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>Whether or not this is running under a Ruby version under 2.0.</p>

  </div>
</div>
<div class="tags">
  <h3>Returns:</h3>
<ul class="return">
  
    <li>
      
        <span class='type'>(<tt>Boolean</tt>)</span>
      
      
      
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


539
540
541</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File '/var/www/sass-pages/.sass/lib/sass/util.rb', line 539</span>

def ruby1?
  Sass::Util::RUBY_VERSION[0] <= 1
end</pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="ruby1_8?-instance_method">
  
    - (<tt>Boolean</tt>) <strong>ruby1_8?</strong> 
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>Whether or not this is running under Ruby 1.8 or lower.</p>

<p>Note that IronRuby counts as Ruby 1.8, because it doesn&#8217;t support the Ruby 1.9 encoding API.</p>

  </div>
</div>
<div class="tags">
  <h3>Returns:</h3>
<ul class="return">
  
    <li>
      
        <span class='type'>(<tt>Boolean</tt>)</span>
      
      
      
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


549
550
551
552
553</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File '/var/www/sass-pages/.sass/lib/sass/util.rb', line 549</span>

def ruby1_8?
  # IronRuby says its version is 1.9, but doesn't support any of the encoding APIs.
  # We have to fall back to 1.8 behavior.
  ironruby? || (Sass::Util::RUBY_VERSION[0] == 1 && Sass::Util::RUBY_VERSION[1] < 9)
end</pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="ruby1_8_6?-instance_method">
  
    - (<tt>Boolean</tt>) <strong>ruby1_8_6?</strong> 
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>Whether or not this is running under Ruby 1.8.6 or lower. Note that lower versions are not officially supported.</p>

  </div>
</div>
<div class="tags">
  <h3>Returns:</h3>
<ul class="return">
  
    <li>
      
        <span class='type'>(<tt>Boolean</tt>)</span>
      
      
      
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


559
560
561</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File '/var/www/sass-pages/.sass/lib/sass/util.rb', line 559</span>

def ruby1_8_6?
  ruby1_8? && Sass::Util::RUBY_VERSION[2] < 7
end</pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="sass_warn-instance_method">
  
    - <strong>sass_warn</strong>(msg) 
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>The same as <code>Kernel#warn</code>, but is silenced by <tt><a href="#silence_sass_warnings-instance_method" title="Sass::Util#silence_sass_warnings (method)">#silence_sass_warnings</a></tt>.</p>

  </div>
</div>
<div class="tags">
  <h3>Parameters:</h3>
<ul class="param">
  
    <li>
      
        <span class='type'>(<tt>String</tt>)</span>
      
      
        <span class='name'>msg</span>
      
      
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


408
409
410
411</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File '/var/www/sass-pages/.sass/lib/sass/util.rb', line 408</span>

def sass_warn(msg)
  msg = msg + "\n" unless ruby1?
  Sass.logger.warn(msg)
end</pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="scope-instance_method">
  
    - (<tt>String</tt>) <strong>scope</strong>(file) 
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>Returns the path of a file relative to the Sass root directory.</p>

  </div>
</div>
<div class="tags">
  <h3>Parameters:</h3>
<ul class="param">
  
    <li>
      
        <span class='type'>(<tt>String</tt>)</span>
      
      
        <span class='name'>file</span>
      
      
      
        &mdash;
        The filename relative to the Sass root
      
    </li>
  
</ul>
<h3>Returns:</h3>
<ul class="return">
  
    <li>
      
        <span class='type'>(<tt>String</tt>)</span>
      
      
      
      
        &mdash;
        The filename relative to the the working directory
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


28
29
30</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File '/var/www/sass-pages/.sass/lib/sass/util.rb', line 28</span>

def scope(file)
  File.join(Sass::ROOT_DIR, file)
end</pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="set_eql?-instance_method">
  
    - (<tt>Boolean</tt>) <strong>set_eql?</strong>(set1, set2) 
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>Tests the hash-equality of two sets in a cross-version manner. Aggravatingly, this is order-dependent in Ruby 1.8.6.</p>

  </div>
</div>
<div class="tags">
  <h3>Parameters:</h3>
<ul class="param">
  
    <li>
      
        <span class='type'>(<tt>Set</tt>)</span>
      
      
        <span class='name'>set1</span>
      
      
      
    </li>
  
    <li>
      
        <span class='type'>(<tt>Set</tt>)</span>
      
      
        <span class='name'>set2</span>
      
      
      
    </li>
  
</ul>
<h3>Returns:</h3>
<ul class="return">
  
    <li>
      
        <span class='type'>(<tt>Boolean</tt>)</span>
      
      
      
      
        &mdash;
        Whether or not the sets are hashcode equal
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


783
784
785
786</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File '/var/www/sass-pages/.sass/lib/sass/util.rb', line 783</span>

def set_eql?(set1, set2)
  return set1.eql?(set2) unless ruby1_8_6?
  set1.to_a.uniq.sort_by {|e| e.hash}.eql?(set2.to_a.uniq.sort_by {|e| e.hash})
end</pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="set_hash-instance_method">
  
    - (<tt>Fixnum</tt>) <strong>set_hash</strong>(set) 
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>Returns the hash code for a set in a cross-version manner. Aggravatingly, this is order-dependent in Ruby 1.8.6.</p>

  </div>
</div>
<div class="tags">
  <h3>Parameters:</h3>
<ul class="param">
  
    <li>
      
        <span class='type'>(<tt>Set</tt>)</span>
      
      
        <span class='name'>set</span>
      
      
      
    </li>
  
</ul>
<h3>Returns:</h3>
<ul class="return">
  
    <li>
      
        <span class='type'>(<tt>Fixnum</tt>)</span>
      
      
      
      
        &mdash;
        The order-independent hashcode of <code>set</code>
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


772
773
774
775</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File '/var/www/sass-pages/.sass/lib/sass/util.rb', line 772</span>

def set_hash(set)
  return set.hash unless ruby1_8_6?
  set.map {|e| e.hash}.uniq.sort.hash
end</pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="silence_sass_warnings-instance_method">
  
    - <strong>silence_sass_warnings</strong> { ... }
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>Silences all Sass warnings within a block.</p>

  </div>
</div>
<div class="tags">
  <h3>Yields:</h3>
<ul class="yield">
  
    <li>
      
        <span class='type'></span>
      
      
      
      
        
        A block in which no Sass warnings will be printed
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


398
399
400
401
402
403</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File '/var/www/sass-pages/.sass/lib/sass/util.rb', line 398</span>

def silence_sass_warnings
  old_level, Sass.logger.log_level = Sass.logger.log_level, :error
  yield
ensure
  Sass.logger.log_level = old_level
end</pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="silence_warnings-instance_method">
  
    - <strong>silence_warnings</strong> { ... }
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>Silence all output to STDERR within a block.</p>

  </div>
</div>
<div class="tags">
  <h3>Yields:</h3>
<ul class="yield">
  
    <li>
      
        <span class='type'></span>
      
      
      
      
        
        A block in which no output will be printed to STDERR
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


387
388
389
390
391
392</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File '/var/www/sass-pages/.sass/lib/sass/util.rb', line 387</span>

def silence_warnings
  the_real_stderr, $stderr = $stderr, StringIO.new
  yield
ensure
  $stderr = the_real_stderr
end</pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="strip_string_array-instance_method">
  
    - (<tt>Array</tt>) <strong>strip_string_array</strong>(arr) 
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>Destructively strips whitespace from the beginning and end of the first and last elements, respectively, in the array (if those elements are strings).</p>

  </div>
</div>
<div class="tags">
  <h3>Parameters:</h3>
<ul class="param">
  
    <li>
      
        <span class='type'>(<tt>Array</tt>)</span>
      
      
        <span class='name'>arr</span>
      
      
      
    </li>
  
</ul>
<h3>Returns:</h3>
<ul class="return">
  
    <li>
      
        <span class='type'>(<tt>Array</tt>)</span>
      
      
      
      
        &mdash;
        <code>arr</code>
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


181
182
183
184
185</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File '/var/www/sass-pages/.sass/lib/sass/util.rb', line 181</span>

def strip_string_array(arr)
  arr.first.lstrip! if arr.first.is_a?(String)
  arr.last.rstrip! if arr.last.is_a?(String)
  arr
end</pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="subsequence?-instance_method">
  
    - (<tt>Boolean</tt>) <strong>subsequence?</strong>(seq1, seq2) 
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>Returns whether or not <code>seq1</code> is a subsequence of <code>seq2</code>. That is, whether or not <code>seq2</code> contains every element in <code>seq1</code> in the same order (and possibly more elements besides).</p>

  </div>
</div>
<div class="tags">
  <h3>Parameters:</h3>
<ul class="param">
  
    <li>
      
        <span class='type'>(<tt>Array</tt>)</span>
      
      
        <span class='name'>seq1</span>
      
      
      
    </li>
  
    <li>
      
        <span class='type'>(<tt>Array</tt>)</span>
      
      
        <span class='name'>seq2</span>
      
      
      
    </li>
  
</ul>
<h3>Returns:</h3>
<ul class="return">
  
    <li>
      
        <span class='type'>(<tt>Boolean</tt>)</span>
      
      
      
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


313
314
315
316
317
318
319
320
321</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File '/var/www/sass-pages/.sass/lib/sass/util.rb', line 313</span>

def subsequence?(seq1, seq2)
  i = j = 0
  loop do
    return true if i == seq1.size
    return false if j == seq2.size
    i += 1 if seq1[i] == seq2[j]
    j += 1
  end
end</pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="substitute-instance_method">
  
    - <strong>substitute</strong>(ary, from, to) 
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>Substitutes a sub-array of one array with another sub-array.</p>

  </div>
</div>
<div class="tags">
  <h3>Parameters:</h3>
<ul class="param">
  
    <li>
      
        <span class='type'>(<tt>Array</tt>)</span>
      
      
        <span class='name'>ary</span>
      
      
      
        &mdash;
        The array in which to make the substitution
      
    </li>
  
    <li>
      
        <span class='type'>(<tt>Array</tt>)</span>
      
      
        <span class='name'>from</span>
      
      
      
        &mdash;
        The sequence of elements to replace with <code>to</code>
      
    </li>
  
    <li>
      
        <span class='type'>(<tt>Array</tt>)</span>
      
      
        <span class='name'>to</span>
      
      
      
        &mdash;
        The sequence of elements to replace <code>from</code> with
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


163
164
165
166
167
168
169
170
171
172
173</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File '/var/www/sass-pages/.sass/lib/sass/util.rb', line 163</span>

def substitute(ary, from, to)
  res = ary.dup
  i = 0
  while i < res.size
    if res[i...i+from.size] == from
      res[i...i+from.size] = to
    end
    i += 1
  end
  res
end</pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="to_hash-instance_method">
  
    - (<tt>Hash</tt>) <strong>to_hash</strong>(arr) 
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>Converts an array of <code>[key, value]</code> pairs to a hash.</p>

  </div>
</div>
<div class="tags">
  
  <div class="examples">
    <h3>Examples:</h3>
    
      <h4></h4>
      <pre class="example code">  to_hash([[:foo, "bar"], [:baz, "bang"]])
    #=> {:foo => "bar", :baz => "bang"}</pre>
    
  </div>
<h3>Parameters:</h3>
<ul class="param">
  
    <li>
      
        <span class='type'>(<tt>Array&lt;(Object, Object)&gt;</tt>)</span>
      
      
        <span class='name'>arr</span>
      
      
      
        &mdash;
        An array of pairs
      
    </li>
  
</ul>
<h3>Returns:</h3>
<ul class="return">
  
    <li>
      
        <span class='type'>(<tt>Hash</tt>)</span>
      
      
      
      
        &mdash;
        A hash
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


39
40
41</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File '/var/www/sass-pages/.sass/lib/sass/util.rb', line 39</span>

def to_hash(arr)
  Hash[arr.compact]
end</pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="undefined_conversion_error_char-instance_method">
  
    - (<tt>String</tt>) <strong>undefined_conversion_error_char</strong>(e) 
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>Returns a string description of the character that caused an <code>Encoding::UndefinedConversionError</code>.</p>

  </div>
</div>
<div class="tags">
  <h3>Parameters:</h3>
<ul class="param">
  
    <li>
      
        <span class='type'>(<tt>Encoding::UndefinedConversionError</tt>)</span>
      
      
        <span class='name'></span>
      
      
      
    </li>
  
</ul>
<h3>Returns:</h3>
<ul class="return">
  
    <li>
      
        <span class='type'>(<tt>String</tt>)</span>
      
      
      
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


277
278
279
280
281
282
283
284</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File '/var/www/sass-pages/.sass/lib/sass/util.rb', line 277</span>

def undefined_conversion_error_char(e)
  # Rubinius (as of 2.0.0.rc1) pre-quotes the error character.
  return e.error_char if rbx?
  # JRuby (as of 1.7.2) doesn't have an error_char field on
  # Encoding::UndefinedConversionError.
  return e.error_char.dump unless jruby?
  e.message[/^"[^"]+"/] #"
end</pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="version_geq-instance_method">
  
    - (<tt>Boolean</tt>) <strong>version_geq</strong>(v1, v2) 
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>Returns whether one version string represents the same or a more recent version than another.</p>

  </div>
</div>
<div class="tags">
  <h3>Parameters:</h3>
<ul class="param">
  
    <li>
      
        <span class='type'>(<tt>String</tt>)</span>
      
      
        <span class='name'>v1</span>
      
      
      
        &mdash;
        A version string.
      
    </li>
  
    <li>
      
        <span class='type'>(<tt>String</tt>)</span>
      
      
        <span class='name'>v2</span>
      
      
      
        &mdash;
        Another version string.
      
    </li>
  
</ul>
<h3>Returns:</h3>
<ul class="return">
  
    <li>
      
        <span class='type'>(<tt>Boolean</tt>)</span>
      
      
      
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


372
373
374</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File '/var/www/sass-pages/.sass/lib/sass/util.rb', line 372</span>

def version_geq(v1, v2)
  version_gt(v1, v2) || !version_gt(v2, v1)
end</pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="version_gt-instance_method">
  
    - (<tt>Boolean</tt>) <strong>version_gt</strong>(v1, v2) 
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>Returns whether one version string represents a more recent version than another.</p>

  </div>
</div>
<div class="tags">
  <h3>Parameters:</h3>
<ul class="param">
  
    <li>
      
        <span class='type'>(<tt>String</tt>)</span>
      
      
        <span class='name'>v1</span>
      
      
      
        &mdash;
        A version string.
      
    </li>
  
    <li>
      
        <span class='type'>(<tt>String</tt>)</span>
      
      
        <span class='name'>v2</span>
      
      
      
        &mdash;
        Another version string.
      
    </li>
  
</ul>
<h3>Returns:</h3>
<ul class="return">
  
    <li>
      
        <span class='type'>(<tt>Boolean</tt>)</span>
      
      
      
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File '/var/www/sass-pages/.sass/lib/sass/util.rb', line 343</span>

def version_gt(v1, v2)
  # Construct an array to make sure the shorter version is padded with nil
  Array.new([v1.length, v2.length].max).zip(v1.split("."), v2.split(".")) do |_, p1, p2|
    p1 ||= "0"
    p2 ||= "0"
    release1 = p1 =~ /^[0-9]+$/
    release2 = p2 =~ /^[0-9]+$/
    if release1 && release2
      # Integer comparison if both are full releases
      p1, p2 = p1.to_i, p2.to_i
      next if p1 == p2
      return p1 > p2
    elsif !release1 && !release2
      # String comparison if both are prereleases
      next if p1 == p2
      return p1 > p2
    else
      # If only one is a release, that one is newer
      return release1
    end
  end
end</pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="windows?-instance_method">
  
    - (<tt>Boolean</tt>) <strong>windows?</strong> 
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>Whether or not this is running on Windows.</p>

  </div>
</div>
<div class="tags">
  <h3>Returns:</h3>
<ul class="return">
  
    <li>
      
        <span class='type'>(<tt>Boolean</tt>)</span>
      
      
      
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


481
482
483</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File '/var/www/sass-pages/.sass/lib/sass/util.rb', line 481</span>

def windows?
  RbConfig::CONFIG['host_os'] =~ /mswin|windows|mingw/i
end</pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="with_extracted_values-instance_method">
  
    - (<tt>Array</tt>) <strong>with_extracted_values</strong>(arr) {|str| ... }
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>Allows modifications to be performed on the string form of an array containing both strings and non-strings.</p>

  </div>
</div>
<div class="tags">
  <h3>Parameters:</h3>
<ul class="param">
  
    <li>
      
        <span class='type'>(<tt>Array</tt>)</span>
      
      
        <span class='name'>arr</span>
      
      
      
        &mdash;
        The array from which values are extracted.
      
    </li>
  
</ul>
<h3>Yields:</h3>
<ul class="yield">
  
    <li>
      
        <span class='type'>(<tt>str</tt>)</span>
      
      
      
      
        &mdash;
        A block in which string manipulation can be done to the array.
      
    </li>
  
</ul>
<h3>Yield Parameters:</h3>
<ul class="yieldparam">
  
    <li>
      
        <span class='type'>(<tt>String</tt>)</span>
      
      
        <span class='name'>str</span>
      
      
      
        &mdash;
        The string form of <code>arr</code>.
      
    </li>
  
</ul>
<h3>Yield Returns:</h3>
<ul class="yieldreturn">
  
    <li>
      
        <span class='type'>(<tt>String</tt>)</span>
      
      
      
      
        &mdash;
        The modified string.
      
    </li>
  
</ul>
<h3>Returns:</h3>
<ul class="return">
  
    <li>
      
        <span class='type'>(<tt>Array</tt>)</span>
      
      
      
      
        &mdash;
        The modified, interpolated array.
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


846
847
848
849
850</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File '/var/www/sass-pages/.sass/lib/sass/util.rb', line 846</span>

def with_extracted_values(arr)
  str, vals = extract_values(arr)
  str = yield str
  inject_values(str, vals)
end</pre>
    </td>
  </tr>
</table>
</div>
    
  </div>

</div>
    
    <div id="footer">
  Generated on Fri Mar  8 20:33:53 2013 by 
  <a href="javascript:if(confirm(%27http://yardoc.org/  \n\nThis file was not retrieved by Teleport Pro, because it is addressed on a domain or path outside the boundaries set for its Starting Address.  \n\nDo you want to open it from the server?%27))window.location=%27http://yardoc.org/%27" tppabs="http://yardoc.org/" title="Yay! A Ruby Documentation Tool">yard</a>
  0.5.3 (ruby-1.8.7).
</div>


  <script type="text/javascript">
  var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
  document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
  </script>
  <script type="text/javascript">
  try {
  var pageTracker = _gat._getTracker("UA-535380-8");
  pageTracker._trackPageview();
  } catch(err) {}</script>


  </body>
</html>